package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;

/**
 * 攻略文章
 */
@Getter
@Setter
public class StrategyDetail extends BaseDomain{

    public static final int STATE_COMMON = 0;//草稿
    public static final int STATE_RELEASE = 1;//发布

    //标题
    private String title;
    //创建时间
    private Date createTime;
    //发布时间
    private Date releaseTime;
    //序号
    private Integer sequence;
    //所属分类
    private StrategyCatalog catalog;
    //封面
    private String coverUrl;
    //状态
    private int state;
    //攻略文章内容
    private StrategyContent strategyContent;

    public String getJsonString(){
        HashMap<Object,Object> map = new HashMap();
        map.put("id",id);
        map.put("title",title);
        map.put("sequence",sequence);
        map.put("state",state);
        map.put("coverUrl",coverUrl);
        if (catalog!=null){
            map.put("catalogId",catalog.getId());
            map.put("catalogName",catalog.getName());
            if (catalog.getStrategy()!=null){
                map.put("strategyId",catalog.getStrategy().getId());
            }
        }
        return JSON.toJSONString(map);
    }
}